package crud.client.data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.client.rpc.IsSerializable;

import crud.client.factory.form.FormItemFactory;
import crud.client.factory.list.grid.ListGridFieldFactory;
import crud.client.factory.validator.field.ValidatorFactory;
import crud.client.factory.validator.table.TableValidatorFactory;

/**
 * @author Eric
 * 
 */

public abstract class Colonne implements Serializable, IsSerializable
{
	private Table table;

	private String codeColonne;
	private String property;
	private String displayValue;
	private int index;
	private int taille;
	private boolean pk;
	private boolean generatedValue = false;
	private boolean nullable = false;
	// private T minValue;
	// private T maxValue;

	private FormItemFactory formItemFactory;
	private ListGridFieldFactory listGridFactory;
	private List<ValidatorFactory> validatorFactoryList = new ArrayList<ValidatorFactory>();
	private List<TableValidatorFactory> tableValidatorFactoryList = new ArrayList<TableValidatorFactory>();

	private String Libelle;
	
	private ColonneDataConverter dataConverter = new ColonneNoDataConverter();

	public Table getTable()
	{
		return table;
	}

	public void setTable(Table table)
	{
		this.table = table;
	}

	public String getCodeColonne()
	{
		return codeColonne;
	}

	public void setCodeColonne(String codeColonne)
	{
		this.codeColonne = codeColonne;
	}

	public int getIndex()
	{
		return index;
	}

	public void setIndex(int index)
	{
		this.index = index;
	}

	public int getTaille()
	{
		return taille;
	}

	public void setTaille(int taille)
	{
		this.taille = taille;
	}

	public boolean isPk()
	{
		return pk;
	}

	public void setPk(boolean pk)
	{
		this.pk = pk;
	}

	public String getLibelle()
	{
		return Libelle;
	}

	public void setLibelle(String libelle)
	{
		Libelle = libelle;
	}

	public String getProperty()
	{
		return property;
	}

	public void setProperty(String property)
	{
		this.property = property;
	}

	public boolean isNullable()
	{
		return nullable;
	}

	public void setNullable(boolean nullable)
	{
		this.nullable = nullable;
	}

	public String getDisplayValue()
	{
		return displayValue;
	}

	public void setDisplayValue(String displayValue)
	{
		this.displayValue = displayValue;
	}

	public boolean isGeneratedValue()
	{
		return generatedValue;
	}

	public void setGeneratedValue(boolean generatedValue)
	{
		this.generatedValue = generatedValue;
	}

	@Override
	public boolean equals(Object obj)
	{
		return this.getCodeColonne().equals(((Colonne) obj).getCodeColonne());
	}

	public FormItemFactory getFormItemFactory()
	{
		return formItemFactory;
	}

	public void setFormItemFactory(FormItemFactory formItemFactory)
	{
		this.formItemFactory = formItemFactory;
	}

	public ListGridFieldFactory getListGridFactory()
	{
		return listGridFactory;
	}

	public void setListGridFactory(ListGridFieldFactory listGridFactory)
	{
		this.listGridFactory = listGridFactory;
	}

	public ColonneDataConverter getDataConverter()
	{
		return dataConverter;
	}

	public void setDataConverter(ColonneDataConverter dataConverter)
	{
		this.dataConverter = dataConverter;
	}

	public List<ValidatorFactory> getValidatorFactoryList()
	{
		return validatorFactoryList;
	}

	public void addValidatorFactory(ValidatorFactory validatorFactory)
	{
		this.validatorFactoryList.add(validatorFactory);
	}




	public List<TableValidatorFactory> getTableValidatorFactoryList()
	{
		return tableValidatorFactoryList;
	}

	
	public void addTableValidatorFactory(TableValidatorFactory validatorFactory)
	{
		this.tableValidatorFactoryList.add(validatorFactory);
	}
	
	
	
}
